<template>
  <div>
    <div class="my-tag">
      <input
      v-focus
      v-model="inputTag"
      @blur="isShow=false"
      @keydown.enter="showInput"
      v-if="isShow"
       class="input"
        type="text"
         placeholder="输入标签" />
      <div @dblclick="show"  v-else class="text">{{value}}</div>
    </div>
  </div>
</template>

<script>
export default {
  props:{
    value:{
      required:true,
      type:String
    }
  },
  name: "VueTestMyTag",
  data() {
    return {
      isShow:'false',
      inputTag:''
    };
  },
  methods: {
    show(){
      this.isShow=true
      this.inputTag=this.value
    },
    showInput(){
      this.$emit('input',this.inputTag);
      this.isShow=false
    }
  },
};
</script>

<style lang="less" scoped>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>